import permission from "./permission";
import { registerRoutes } from '../src/modules';

const { REACT_APP_ENV } = process.env;

const devToolRoutes = REACT_APP_ENV ? [
  {
    name: 'permissionConfig',
    path: '/admin/dev/permission',
    component: './PermissionConfig',
    hideInMenu: true,
  },
] : [];

/**
 * 基础路由结构,请勿随意调整
 */
export default [
  {
    icon: 'dashboard',
    path: '/',
    component: '@/layouts/NormalLayout',
    routes: [
      ...registerRoutes(),
      {
        path: '/admin',
        routes: [
          {
            name: 'login',
            path: '/admin/login',
            component: './user/Login',
            hideInMenu: true,
          },
          {
            path: '/admin',
            component: '@/layouts/AdminLayout',
            routes: [
              ...permission,
              {
                name: 'account',
                path: '/admin/account',
                hideInMenu: true,
                routes: [
                  {
                    name: 'settings',
                    path: '/admin/account/settings',
                    component: './account/settings'
                  },
                  {
                    path: '/admin/account',
                    redirect: '/admin/account/settings'
                  },
                  {
                    component: './404',
                  }
                ]
              },
              ...devToolRoutes,
              {
                component: './404',
              }
            ]
          },
          {
            component: './404',
          }
        ]
      },
      {
        component: './404',
      }
    ]
  }
];
